<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.wxpay.util.WXPayUtil"%>
<%@page import="java.io.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%
	System.out.println("----进入到了该页面---");
	BufferedReader reader = request.getReader();
	String line = "";
	StringBuffer inputString = new StringBuffer();
	try {
		while ((line = reader.readLine()) != null) {
			inputString.append(line);
		}
		request.getReader().close();
		System.out.println("----接收到的报文---" + inputString.toString());
		Map json = WXPayUtil.xmlToMap(inputString.toString());
		//String appid=json.get("appid")+"";
		//String mch_id=json.get("mch_id")+"";
		if (json.get("return_code").equals("SUCCESS")) {
			if (json.get("result_code").equals("SUCCESS")) {
				String transaction_id = json.get("transaction_id") + "";//微信支付订单号
				String out_trade_no = json.get("out_trade_no") + "";//商户订单号
				String openid = json.get("openid") + "";
				String trade_type = json.get("trade_type") + "";
				//接下来是做自己的业务处理
				//开一个线程，更新订单状态
				
			}
		}
		//告诉微信服务器，我收到信息了，不要在调用回调action了
		response.getWriter().write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
		System.out.println("----结束---" + inputString.toString());
	} catch (Exception e) {
		e.printStackTrace();
	}
%>